package com.naiterui.ehp.bs.wechat.protocol.result;

import java.io.Serializable;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.naiterui.ehp.bs.wechat.exception.WeChatErrorCode;

/**
 * 微信api返回结果基本信息
 * @author zhoupeipei
 * @date 2019-06-12 14:22
 * @since 1.0.0
 */
public class BaseResult implements Serializable {
    private static final long serialVersionUID = -3942094213632620246L;
    /**
     * 异常码
     */
    @JsonProperty("errcode")
    private Integer errorcode;
    /**
     * 异常信息
     */
    private String errmsg;

    public Integer getErrorcode() {
        return errorcode;
    }

    public void setErrorcode(Integer errorcode) {
        this.errorcode = errorcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public boolean successReturn() {
        if (null == errorcode || WeChatErrorCode.CODE_OK_0.getCode() == errorcode) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
